<html>
<head><meta charset="utf-8"><title>async database interface · wg-database · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/193127-wg-database/index.html">wg-database</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/193127-wg-database/topic/async.20database.20interface.html">async database interface</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="161990917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/193127-wg-database/topic/async%20database%20interface/near/161990917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> weiznich <a href="https://rust-lang.github.io/zulip_archive/stream/193127-wg-database/topic/async.20database.20interface.html#161990917">(Mar 28 2019 at 20:42)</a>:</h4>
<p>I've started to play a bit around trying to prototype a primitive async database interface.<br>
There are several hard constrains for making such interface usable in diesel:</p>
<ul>
<li>Connections are <code>Send</code> but not <code>Sync</code></li>
<li>The resulting implementation should be usable with tokio, which means that the constructed futures must be <code>Send</code></li>
<li>The api should be similar to the existing diesel api, for example transactions should be realized with closures or something equally accessible </li>
</ul>
<p>I've put together a <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=1a090c56ab5fbcd61e6fd0363150d6ca" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=1a090c56ab5fbcd61e6fd0363150d6ca">small playground</a> demonstrating that use case. To shorten that story: I'm not able to find an way to make that compiling. I think the first step towards an async database interface is to find a way to fix that.</p>



<a name="162075140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/193127-wg-database/topic/async%20database%20interface/near/162075140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/193127-wg-database/topic/async.20database.20interface.html#162075140">(Mar 29 2019 at 19:03)</a>:</h4>
<p><span class="user-mention" data-user-id="215423">@weiznich</span> I'm not sure how useful this really is, but <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=59516c212ac5b9d4805eb974a023ba75" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=59516c212ac5b9d4805eb974a023ba75">that interface is ~possible</a></p>



<a name="162352395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/193127-wg-database/topic/async%20database%20interface/near/162352395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> weiznich <a href="https://rust-lang.github.io/zulip_archive/stream/193127-wg-database/topic/async.20database.20interface.html#162352395">(Apr 02 2019 at 16:47)</a>:</h4>
<p>That's certainly a step into the right direction, but without closures such an interface would be quite wired to work with.</p>



<a name="162354958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/193127-wg-database/topic/async%20database%20interface/near/162354958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/193127-wg-database/topic/async.20database.20interface.html#162354958">(Apr 02 2019 at 17:16)</a>:</h4>
<p>Yeah, unfortunately async closures have a lot of issues still (I wasn’t able to get the HRTB bounds there to line up with them, that’s why I had to switch it out for a function)</p>



<a name="163206650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/193127-wg-database/topic/async%20database%20interface/near/163206650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Doddzilla <a href="https://rust-lang.github.io/zulip_archive/stream/193127-wg-database/topic/async.20database.20interface.html#163206650">(Apr 12 2019 at 16:50)</a>:</h4>
<p>Hello all! Definitely stoked that we have a database WG now! I've been doing a lot of work with the <a href="https://github.com/mongodb-labs/mongo-rust-driver-prototype" target="_blank" title="https://github.com/mongodb-labs/mongo-rust-driver-prototype">mongo driver</a>, and built and the <a href="https://github.com/thedodd/wither" target="_blank" title="https://github.com/thedodd/wither">Wither project</a> (an ODM) on top of it for model driven interaction with the database.</p>
<p>Definitely lots of additional work to be done, and the MongoDB team is apparently considering building a new one which will be maintained by the company and such. Who knows how long that will take, or if it will even happen. So I wanted to see if there is any interest in forking the current repo for the WG to maintain (which I would love to be a part of).</p>



<a name="163206755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/193127-wg-database/topic/async%20database%20interface/near/163206755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Doddzilla <a href="https://rust-lang.github.io/zulip_archive/stream/193127-wg-database/topic/async.20database.20interface.html#163206755">(Apr 12 2019 at 16:51)</a>:</h4>
<p>Essentially I was wanting to refactor the current lib to give it an async foundation (on top of tokio), and then finish building out its missing features. After that, the Wither project can be updated to support the async interface.</p>
<p>Let me know if you have any thoughts or are interested in this idea.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>